package com.fengye.sphere.common.core;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 异步工具类
 *
 * @author gaohaiqing
 * @since 2023/12/10
 */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class AsyncTools {

    /**
     * 特别关注newSingleThreadExecutor()的实现方式
     */
    private static final ExecutorService executorService = Executors.newSingleThreadExecutor();


    public static void async(Runnable runnable) {
        executorService.execute(runnable);
    }
}